const express = require('express');
const systemModule = require('../func/system-module').init();
const systemConfig = require('../func/system-config').init();
const orgStruct = require('../func/org-Struct').init();
const partnersDict = require('../func/partners-dict').init();
const curUserInfo = require('../func/cur-user-info').init();
const iframeDict = require('../func/iframe-dict').init();
const degree = require('../func/data-degree').init();
module.exports = class router {
    constructor() {
        this.router = express.Router();
        this.webTools = global.webTools;
        this.DB = global.DataBase;
        this.moment = global.moment;
        this.func = {
            systemModule: systemModule,
            systemConfig: systemConfig,
            orgStruct: orgStruct,
            partnersDict: partnersDict,
            curUserInfo: curUserInfo,
            iframeDict: iframeDict,
            degree: degree
        }
    }

    static init() {
        return new this();
    }



    loadLogic(path, params) {
        if (path.indexOf('.js') < 0) {
            path += '.js';
        }
        let realPath = `../../logic/${path}`;
        return require(realPath).init(params);
    }

    Success(Result, Data) {
        let cb = {
            Result: Result,
            Data: Data
        };
        return cb;
    }

    Error(msg, err) {
        let cb = {
            Result: 0,
            Msg: msg,
            err: err
        };
        log.error(err);
        return cb;
    }

}
